package com.hw.paltfrom.controller.system;


import java.util.List;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hw.paltfrom.mongoDto.ExceptionLog;
import com.hw.paltfrom.pack.ResponseResult;
import com.hw.paltfrom.rescode.HWSystemCode;
import com.hw.paltfrom.utils.MongodbUtil;
import com.hw.paltfrom.utils.SpringUtil;
import com.hw.paltfrom.vo.BaseAreaVo;
import com.hw.paltfrom.vo.SystemLogVo;


/**
 *系统日志
 * 曹荣坤
 * 2019年11月6日15:06:04
 */
@RestController
@RequestMapping("/SystemLog")
public class SystemLogController {

	@RequestMapping(value = "/exception")
	public Map<String, Object> exception(SystemLogVo vo) {

		PageHelper.startPage(vo.getPageNum(), vo.getPageSize());
		MongodbUtil bean = SpringUtil.getBean(MongodbUtil.class);
		ExceptionLog log = new ExceptionLog();
		String[] key = { "_class" };
		String[] value = { "com.hw.paltfrom.mongoDto.ExceptionLog" };
		List<? extends Object> find = bean.findByTime(log, key, value, "ExceptionLog", vo.getStartTime(),
				vo.getEndTime());
		PageInfo<? extends Object> pageInfo = new PageInfo<>(find);
		return ResponseResult.successNotice(HWSystemCode.SUCCESS, pageInfo);

	}

	@RequestMapping(value = "/test")
	public Map<String, Object> test(BaseAreaVo vo) {

		MongodbUtil bean = SpringUtil.getBean(MongodbUtil.class);
		ExceptionLog log = new ExceptionLog();
		String[] key = { "_class" };
		String[] value = { "com.hw.paltfrom.mongoDto.ExceptionLog" };
//		LocalDateTime startTime = LocalDateTime.ofEpochSecond(1571703469000l, 0, ZoneOffset.ofHours(8));
//		LocalDateTime endTime = LocalDateTime.ofEpochSecond(1571703589000l, 0, ZoneOffset.ofHours(8));
		List<? extends Object> find = bean.findByTime(log, key, value, "ExceptionLog", 1572921564750l, 1572921564760l);
		// List<? extends Object> find = bean.find(log, key, value,
		// "ExceptionLog");
		return ResponseResult.successNotice(HWSystemCode.SUCCESS, find);
	}
}
